<html>
  <head>
    <meta charset="utf8" />
    <title>Informations sur les équipes</title>
	<link rel="stylesheet" href="style.css" />
  </head>
  <body>
<?php include("connexion-db.php");
include("retour-index.php"); ?>
<?php
$query_info = 'SELECT NOM_CLUB, NOM_EQUIPE
FROM EQUIPE E, CATEGORIE CA, CLUB C
WHERE E.ID_EQUIPE="'.$_GET['id-equipe'].'"
AND E.ID_CAT = CA.ID_CAT
AND CA.ID_CLUB = C.ID_CLUB';

$res_info = $db->query($query_info);
$data_info = $res_info->fetch();
?>
<p>Bilan de l'équipe <?php echo $data_info['NOM_CLUB'].' '.$data_info['NOM_EQUIPE']; ?> : <br />

<?php
$query_gagne = 'select count(*) as G from
((select ID_RENCONTRE
from RENCONTRE R, EQUIPE E
where E.ID_EQUIPE="'.$_GET['id-equipe'].'"
and R.ID_EQUIPE1=E.ID_EQUIPE
and R.SCORE1!="-1"
and R.SCORE1>R.SCORE2)
UNION
(select ID_RENCONTRE
from RENCONTRE R, EQUIPE E
where E.ID_EQUIPE="'.$_GET['id-equipe'].'"
and R.ID_EQUIPE2=E.ID_EQUIPE
and R.SCORE2!="-1"
and R.SCORE2>R.SCORE1)) AS T';
$res_gagne = $db->query($query_gagne);
$data_gagne = $res_gagne->fetch();
?>

<?php
$query_perdu = 'select count(*) as P from
((select ID_RENCONTRE
from RENCONTRE R, EQUIPE E
where E.ID_EQUIPE="'.$_GET['id-equipe'].'"
and R.ID_EQUIPE1=E.ID_EQUIPE
and R.SCORE1!="-1"
and R.SCORE1<R.SCORE2)
UNION
(select ID_RENCONTRE
from RENCONTRE R, EQUIPE E
where E.ID_EQUIPE="'.$_GET['id-equipe'].'"
and R.ID_EQUIPE2=E.ID_EQUIPE
and R.SCORE2!="-1"
and R.SCORE2<R.SCORE1)) AS T';
$res_perdu = $db->query($query_perdu);
$data_perdu = $res_perdu->fetch();
?>

<?php
$query_nul = 'select count(*) as N from
((select ID_RENCONTRE
from RENCONTRE R, EQUIPE E
where E.ID_EQUIPE="'.$_GET['id-equipe'].'"
and R.ID_EQUIPE1=E.ID_EQUIPE
and R.SCORE1!="-1"
and R.SCORE1=R.SCORE2)
UNION
(select ID_RENCONTRE
from RENCONTRE R, EQUIPE E
where E.ID_EQUIPE="'.$_GET['id-equipe'].'"
and R.ID_EQUIPE2=E.ID_EQUIPE
and R.SCORE2!="-1"
and R.SCORE2=R.SCORE1)) AS T';
$res_nul = $db->query($query_nul);
$data_nul = $res_nul->fetch();
?>

Nombre de matches gagnés : <?php echo $data_gagne['G']; ?><br />
Nombre de matches perdus : <?php echo $data_perdu['P']; ?><br />
Nombre de matches nuls : <?php echo $data_nul['N']; ?><br />
</p>
  </body>
</html>
